import request from '@/utils/http'
import axios from 'axios'


//获取广场列表
export const GetSquareListService = () => {
  return request.get('/article/list')
}

//获取某文章的全部评论
export const GetCommentListService = (articleId) => {
  console.log('评论列表');
  return request.get(`/article/comment/list?articleId=${articleId}`)
}

//发布文章
export const PostArticleService = (data) => {
  return request.post('/article', data)
}

//给文章点赞
export const PostArticleLikeService = (articleId) => {
  return request.post(`/article/like?articleId=${articleId}`)
}

//  文件上传
export function upload(fileData) {
  return request({
      method: 'post',
      url: '/upload',
      headers: {
          'Content-Type': 'multipart/form-data' // 设置请求头为 multipart/form-data
      },
      data: fileData
  })
}

//发送评论
export const sendComment = (articleId,data) => {
  return request({
    url: `/article/comment?articleId=${articleId}`,
    method: 'POST',
    data
  })
}

